package cc.mrbird.febs.system.service.impl;

import cc.mrbird.febs.system.dao.TRoleAreaMapper;
import cc.mrbird.febs.system.domain.TRoleArea;
import cc.mrbird.febs.system.service.ITRoleAreaService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;

/**
 * @author dtwei
 */
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class TRoleAreaServiceImpl extends ServiceImpl<TRoleAreaMapper, TRoleArea> implements ITRoleAreaService {

    @Override
    public List<TRoleArea> getRoleAreasByRoleId(String roleId) {
        return baseMapper.selectList(new LambdaQueryWrapper<TRoleArea>().eq(TRoleArea::getRoleId, roleId));
    }

    @Override
    public void deleteRoleAreasByRoleId(String[] roleIds) {
        List<String> list = Arrays.asList(roleIds);
        baseMapper.delete(new LambdaQueryWrapper<TRoleArea>().in(TRoleArea::getRoleId, list));
    }
}
